//
//  LTLWelcome.m
//  WeiBo
//
//  Created by LiTaiLiang on 16/9/29.
//  Copyright © 2016年 LTL. All rights reserved.
//

#import "LTLWelcome.h"
#import "CopyiPhoneFadeView.h"
#import "LTLTabBarController.h"
@interface LTLWelcome ()

@end

@implementation LTLWelcome

- (void)viewDidLoad {
    [super viewDidLoad];
    
    LTLModel *shuJu = [LTLModel read];
    
//    NSLog(@"%@",shuJu.user.avatar_hd);
//    NSLog(@"%@",shuJu.user.name);
    
    UIImageView *image =  [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ad_background"]];
    
    image.frame = self.view.bounds;
    
    [self.view addSubview:image];
    
    //UIImageView *icon =  [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"avatar_default_big"]];
    UIImageView *icon =  [[UIImageView alloc]init];
    
    [icon sd_setImageWithURL:[NSURL URLWithString:shuJu.avatar_hd] placeholderImage:[UIImage imageNamed:@"avatar_default_big"]];
    
    [icon sizeToFit];
    //头像位置
    icon.centerX = self.view.centerX;
    
    icon.centerY = self.view.centerY;
    
    ///开启遮罩
    icon.layer.masksToBounds = YES;
    ///设置为图片宽度的一半出来为圆形
    icon.layer.cornerRadius          =         icon.image.size.height/2.0f;
    ///头像边框宽度
//    icon.layer.borderWidth           =          3;
    
    [self.view addSubview:icon];
    ///渐变文字
    CopyiPhoneFadeView *wel = [[CopyiPhoneFadeView alloc]initWithFrame:CGRectMake(0, 0, 350, 40)];
    
    wel.text = @"欢迎使用!";
    wel.backColor = [UIColor blackColor];
    wel.foreColor = [UIColor whiteColor];
    wel.font = [UIFont systemFontOfSize:25];
    wel.alignment = NSTextAlignmentCenter;
    wel.centerX = icon.centerX ;
    wel.centerY = self.view.centerY-100;
    [wel iPhoneFadeWithDuration:2];
    [self.view addSubview:wel];
    icon.alpha = 0;
    //动画
    [UIView animateWithDuration:1.5 animations:^{
        
        if (shuJu.access_token) {
            icon.centerY = self.view.centerY-200;
            icon.alpha = 1;
            wel.text = [NSString stringWithFormat:@"%@,欢迎使用!" , shuJu.name];
            
        }
        
    } completion:^(BOOL finished) {
//        [NSThread sleepForTimeInterval:1.5f];
        UIWindow *win = [UIApplication sharedApplication].keyWindow;
        win.rootViewController = [[LTLTabBarController alloc]init];
        
    }];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
